package Models

import (
	"fmt"
	"gorm.io/gorm"
	"gorm.io/gorm/logger"
	"gorm_study/Table"
	"gorm_study/libs"
)

func Remove() {
	libs.DB.Where("age > ?", 30).Delete(&Table.Student{})
}

func LogicRemove() {
	libs.DB.Where("age > ?", 12).Delete(&Table.Student{})

	println(libs.DB.Unscoped().Where("age = 20").Find(&Table.Student{}))
}

func GetUnscoped() {
	db := libs.DB.Session(
		&gorm.Session{Logger: logger.Default.LogMode(logger.Info)},
	)
	list := []Table.Student{}
	_ = db.Unscoped().Where("IsDEL IS NOT NULL").Find(&list)
	fmt.Println(len(list))
}
